﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MVCPets.Extensions;

namespace MVCPets.Tests.Extensions
{
  [TestClass]
  public class NumericExtensionTests
  {
    [TestMethod]
    public void Test_IsNaturalNumber()
    {
      Assert.IsTrue("1".IsNaturalNumber());
      Assert.IsFalse("A".IsNaturalNumber());
    }

    [TestMethod]
    public void ISwholeNumber()
    {
      Assert.IsTrue("1".IsWholeNumber());
      Assert.IsFalse("1.1".IsWholeNumber());
    }

    [TestMethod]
    public void Test_IsInteger()
    {
      Assert.IsTrue("1".IsInteger());
      Assert.IsFalse("A".IsInteger());
      Assert.IsFalse("1.1".IsInteger());
    }

    [TestMethod]
    public void Test_Is_Number()
    {
      Assert.IsTrue("1".IsNumber());
      Assert.IsFalse("A".IsNumber());
      Assert.IsTrue("1.1".IsNumber());
    }

    [TestMethod]
    public void Test_IsEven()
    {
      Assert.IsTrue(2.IsEven());
      Assert.IsFalse(3.IsEven());
    }

    [TestMethod]
    public void Test_IsOdd()
    {
      Assert.IsFalse(2.IsOdd());
      Assert.IsTrue(3.IsOdd());
    }

    [TestMethod]
    public void Test_IsBetween()
    {
      Assert.IsTrue(0.IsBetween(-1, 1));
      Assert.IsTrue(1.IsBetween(-1, 1, BetweenOptions.IncludeBoth));
      Assert.IsTrue(0.IsBetween(0, 2, BetweenOptions.IncludeBoth));
      Assert.IsTrue(0.IsBetween(0, 2, BetweenOptions.IncludeLower));
      Assert.IsFalse(2.IsBetween(0, 2, BetweenOptions.IncludeLower));
      Assert.IsTrue(2.IsBetween(0, 2, BetweenOptions.IncludeHigher));
      Assert.IsFalse(0.IsBetween(0, 2, BetweenOptions.IncludeHigher));
    }

    [TestMethod]
    public void Test_Random()
    {
      Assert.IsTrue(5.Random() <= 5);
      Assert.IsTrue(5.Random(10) >= 5);
      Assert.IsTrue(5.Random(10) <= 10);
    }

    [TestMethod]
    public void Test_ToExcelDate()
    {
      Assert.IsTrue(50.ToExcelDate().ToString().HasValue());
      Assert.IsTrue(70.ToExcelDate().ToString().HasValue());
    }
  }
}
